package com.wl.cloud.system.support.vo;

import com.wl.cloud.core.dto.AbstractBaseVO;
import com.wl.cloud.core.tree.TreeNode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 资源表
 *
 * @author wanglin
 * @since 2023-09-18
 */
@Data
@Schema(description = "资源表")
public class SysResourceVO extends AbstractBaseVO implements TreeNode<String> {
    /**
     * 是否已删除:1:删除
     */
    @Schema(description = "是否已删除:1:删除")
    private Boolean deleted;
    /**
     * 资源类型ID,大模块的分类id
     */
    @Schema(description = "资源类型ID,大模块的分类id")
    private String categoryId;

    /**
     * 描述
     */
    @Schema(description = "描述")
    private String description;
    /**
     * 资源层级
     */
    @Schema(description = "资源层级")
    private Integer level;
    /**
     * 资源名称
     */
    @Schema(description = "资源名称")
    private String name;
    private String categoryName;
    /**
     * 上级资源id
     */
    @Schema(description = "上级资源id")
    private String parentId;

    private String url;

    private List<SysResourceVO> children;

    @Override
    public String id() {
        return this.getId();
    }

    @Override
    public String parentId() {
        return this.getParentId();
    }

    @Override
    public Boolean root() {
        return StringUtils.isBlank(this.getParentId());
    }

    @Override
    public void setChildren(List children) {
        this.children = children;
    }

    @Override
    public List<? extends TreeNode<String>> getChildren() {
        return this.children;
    }
}